package xyz.robinbingo.leetcode.a20.b05.c11;

public class Solution {
    public double myPow(double x, int n) {
        if (x == 0 && n == 0) {
            throw new RuntimeException("error");
        }
        if (x == 0) {
            return 0;
        }
        double result = 1.0;

        for (int i = 1; i <= Math.abs((long) n); i++) {
            result = result * x;
        }
        if (n < 0) {
            result = 1 / result;
        }
        return result;
    }
}